Python 十分钟入门 http://www.runoob.com/w3cnote/python-ten-minute-introductory-tutorial.html
Python 菜鸟教程 http://www.runoob.com/python/python-tutorial.html
PyCharm安装Numpy https://jingyan.baidu.com/article/3aed632ed414d5701080912e.html
python 文件读取
with open(xml_path, "r") as fr:
content = fr.read()
python读取文件时提示"UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 205: illegal multibyte sequence"
解决办法1.
with open(xml_path, "r", encoding="UTF-8") as fr:
content = fr.read()
解决办法2.
with open(xml_path, "rb") as fr:
content = fr.read()
Python 操作符
1. and 比 or 有更高的优先级
2. x^y 在 python中为 x**y
Python类class中方法的self问题,
self代表类的实例,而非类
类的方法与普通的函数只有一个特别的区别——它们必须有一个额外的第一个参数名称, 按照惯例它的名称是 self。
#!/usr/bin/python
# -*- coding: UTF-8 -*-
class Employee:
'所有员工的基类'
empCount = 0
def __init__(self, name, salary):
self.name = name
self.salary = salary
Employee.empCount += 1
def displayCount(self):
print("Total Employee %d" % Employee.empCount)
def displayEmployee(self):
print("Name : ", self.name, ", Salary: ", self.salary)
t = Employee("sff", "1000")
t.displayEmployee()
Python缩进问题: