review what i studied `date` - 2017-4-12

python 連接字符串 int + srt 


>>> a = 1
>>> b = 'xuhui'
>>> a + b
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'str'
>>> b + str(a)
'xuhui1'
#將int轉換爲字符串這樣就不會報錯了


執行一條命令並把返回的值轉換爲列表 

>>> import os
>>> os.popen('ls').read().split()
['autoindex.conf', 'fcgid.conf', 'meterial.conf', 'php.conf', 'README', 'ssl.conf', 'userdir.conf', 'zabbix.conf', 'zabbix.conf.rpmsave']


 解決Apache autoindex中文亂碼問題 autoindex.conf 文件有自己的編碼設置 

在配置文件中添加此行

IndexOptions Charset=UTF-8
#GBK|GB2312


 smb.conf  新學到的參數

 

inherit acls = yes        允許繼承文件acl
create mask = 0664        創建文件的默認權限

 

nginx 實現識別客戶端IP地址重定向地址

if ($remote_addr ~* ^10\.1\.1\.(.*?)$)
{
rewrite ^(.*)$  http://10.1.1.101/;
}
#將10.1.1.0網段的地址全部重定向到 10.1.1.101這臺機器上


$1 的含義 
#例如:
if ($remote_addr ~* ^10\.1\.1\.(.*?)$) 
{
rewrite ^(.*)$  http://10.1.1.101$1;
}
這其中的$1就是前邊“^(.*)$”
#         括號中的值
打個比方我訪問的是地址10.1.1.1/web
那麼“^(.*)$” 就是“/web”,我就會被重#定向到 10.1.1.101/web目錄下 

# 再舉個例子: 
if ($remote_addr ~* ^10\.1\.1\.(.*?)$) 
{ 
set $uip $1
return 403 "Forbidden 10.1.1.$uip"; 
} 
#這其中的$1是前邊“(.*?)”中的值 後來又被賦給變量$uip
最後在頁面上顯示的結果是Forbidden #10.1.1.254


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章