Python常用函数

一、取绝对值-abs()

1 a = -3
2 a =  abs(a)
3 print(a)
View Code

二、字符串转字典-eval()

 1 arg = '''{
 2             'bakend': 'www.oldboy.org',
 3             'record':{
 4                 'server': '100.1.7.9',
 5                 'weight': 20,
 6                 'maxconn': 30
 7             }
 8 }'''
 9 
10 arg = eval(arg)
11 
12 print(arg)
View Code

 

posted on 2018-03-27 18:16  haitun425  阅读(96)  评论(0编辑  收藏  举报

导航