Python int與string之間的轉化


string-->int
1、10進制string轉化為int
  int('12')
2、16進制string轉化為int
  int('12', 16)
int-->string
1、int轉化為10進制string
  str(18)
2、int轉化為16進制string
  hex(18)
 
json轉化為字典
import json json_str = """ { "id" : 90, "name" : "python", "url" : "http://www.v2ex.com/go/python", "title" : "Python", "title_alternative" : "Python", "topics" : 7646, "stars" : 4862, """ res = json.loads(json_str) print(res['id']) # 90 print(res['name']) # python print(res['url']) # http://www.v2ex.com/go/python


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM