![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
文章平均质量分 70
J先生的编程笔记
一杯茶,一包烟,一个 BUG 改一天!
展开
-
5.pandas:数据读写
5.5 从xml读取数据import pandas as pd#lxml库:#大文件处理方面性能优异#与pandas整合起来,从XML文件中获取所需数据并将其转换为DataFrame对象#详见:http://lxml.de/index.htmlfrom lxml import objectifyxml = objectify.parse('books.xml')#根结构中的每个结点和原创 2018-01-18 21:47:31 · 311 阅读 · 0 评论 -
Dict
Dict1 Initd = dict(name='JJ', age=20) # {'name': 'JJ', 'age': 20}d = dict(zip(['name', 'age'], ['JJ', 20])) # {'name': 'JJ', 'age': 20}d = dict.fromkeys(['a', 'b']) # {'a': None, 'b': None}d = d...原创 2019-04-09 20:40:57 · 264 阅读 · 0 评论 -
Python sorted() 函数
Python sorted() 函数转载 2019-04-09 20:15:27 · 105 阅读 · 0 评论 -
List
Listlist = ['a', 'b', 'c', 'd']# METHOD 1# index: 0 value: a# index: 1 value: b# index: 2 value: c# index: 3 value: dfor item in list: print("index: %s value: %s" % (list.in...原创 2019-04-09 20:08:21 · 141 阅读 · 0 评论 -
Range
# Rangerange(stop)range(start, stop[, step])list(range(5)) # [0, 1, 2, 3, 4]list(range(0)) # []list(range(0, 30, 5)) # [0, 5, 10, 15, 20, 25]# The last element is close to STARTlist(range(0, ...转载 2019-04-09 10:48:35 · 1172 阅读 · 0 评论 -
set
setset1 = set([1, 2, 3])set2 = set([2, 3, 4])print(set1.union(set2))print(set1.intersection(set2))print(set1.difference(set2))# {1, 2, 3, 4}# {2, 3}# {1}Referencepython两个 list 获取交集,并集,差集的...原创 2019-04-12 12:20:56 · 1109 阅读 · 0 评论 -
pip
pippip install --upgrade pandas原创 2019-04-12 08:38:24 · 117 阅读 · 0 评论 -
OSError: Initializing from file failed
# 使用pandas直接读取文件报错# OSError: Initializing from file failed# 一般是因为文件名中带有中文# 可做如下处理with open(fileName) as f: csv_data = pd.read_csv(f)...原创 2019-04-07 21:56:48 · 1081 阅读 · 0 评论 -
range()
range()import numpy as np # TypeError: 'float' object cannot be interpreted as an integerprint([i for i in range(0, 1.1, 0.1)])print([i for i in np.arange(0, 1.1, 0.1)]) # [0.0, 0.1, 0.2, 0.3000000...原创 2019-04-10 22:31:07 · 257 阅读 · 0 评论 -
global
Python 使用全局变量转载 2019-04-10 20:04:52 · 250 阅读 · 0 评论 -
', " and '''
s = "str'1'" # str'1's = 'str"1"' # str"1"s = "hello \world" # hello worlds = """helloworld"""# hello# worldReferencepython单引号和双引号的区别Python单引号、双引号和三双引号的区别...原创 2019-04-09 23:02:22 · 111 阅读 · 0 评论