python中的eval用法
eval 方法能使字串本身的引號去掉,保留字元的原本屬性。eval這個函式就是在返回它覺得正確的那個值。
>>>str1 = "[{11,22},{22,33},{33,44},{44,55}]"
>>>type(str1)
<class 'str'>
>>>list1 = eval(str1)
>>>list1
[{11,22},{22,33},{33,44},{44,55}]
>>>type(list)
<class 'list'>
>>>a = input("請輸入:")
>>>__import__("os").getcwd()
>>>eval(a)
C:\Python27 # 輸出結果是儲存程式碼的資料夾路徑
相關文章
- Python eval的用法及注意事項Python
- Python中eval與exec的使用及區別Python
- Python中eval帶來的潛在風險Python
- Python中eval函式的表示式如何使用Python函式
- Python 中 eval 與 exec 的相同點和不同點Python
- python中return的用法Python
- Python中if的基本用法Python
- js中eval詳解,用Js的eval解析JSON中的注意點JSON
- 深度辨析 Python 的 eval() 與 exec()Python
- Python中eval函式是什麼?如何使用?Python函式
- Python中eval如何使用?其作用是什麼?Python
- Python-eval()函式Python函式
- Python中return self的用法Python
- Zsh 開發指南(第十六篇 alias 和 eval 的用法)
- ast.literal_eval替代eval將字串形式的表示式解析為 Python 物件AST字串Python物件
- python中zip()函式的用法Python函式
- 淺談python中的xpath用法Python
- Python中paramiko 模組的用法Python
- Python中lambda表示式的用法Python
- Python中operator 模組的用法Python
- Python中pathlib 模組的用法Python
- Python中itertools 模組的用法Python
- Python中的selenium的簡單用法Python
- Python中的split()函式的用法Python函式
- JSON.parse()與JSON.stringify()的用法,以及eval()和new FunctionJSONFunction
- Python中__init__的用法和理解Python
- python 中 pipenv 用法筆記Python筆記
- Python中Collections.counter用法Python
- Python numpy中矩陣的用法總結Python矩陣
- Python中 sys.argv[]的用法解釋Python
- 簡單介紹python的input,print,eval函式Python函式
- eval
- Python中urllib和urllib2庫的用法Python
- Python 中 key 引數的含義及用法Python
- Python中key引數的含義及用法Python
- python中upper函式的用法是什麼?Python函式
- 什麼是eval()?eval是用來幹什麼的?
- Ruby class_eval and instance_eval notes