TypeError:需要类似字节的对象,而不是'str'
在执行下面的python代码时将错误的表格数据保存在Csv文件中.不知道如何获得rideup.pls帮助我.
import csv
import requests
from bs4 import BeautifulSoup
url='http://www.mapsofindia.com/districts-india/'
response=requests.get(url)
html=response.content
soup=BeautifulSoup(html,'html.parser')
table=soup.find('table', attrs={'class':'tableizer-table'})
list_of_rows=[]
for row in table.findAll('tr')[1:]:
list_of_cells=[]
for cell in row.findAll('td'):
list_of_cells.append(cell.text)
list_of_rows.append(list_of_cells)
outfile=open('./immates.csv','wb')
writer=csv.writer(outfile)
writer.writerow(["SNo", "States", "Dist", "Population"])
writer.writerows(list_of_rows)
Run Code Online (Sandbox Code Playgroud)
在最后一行上方.
在安装python和django后,我对python和django完全不熟悉.我正在使用virtula env将virtualenv用于django项目目的.我使用pip安装virtualenv.有什么问题请帮助我,谢谢
pip install virtualenv # got install successfully
Run Code Online (Sandbox Code Playgroud)
我跑的时候有错误消息:
C:\Users\gshiv\Desktop\DjangoProject>virtualenv
Run Code Online (Sandbox Code Playgroud)
'virtualenv'不被识别为内部或外部命令,可操作程序或批处理文件.
我有以下代码:
在.py文件中:
class newsaleorderline(models.Model):
_inherit='sale.order.line'
supply_tax_id = fields.Many2many('account.tax',string='Supply Taxes',domain=['|', ('active', '=', False), ('active', '=', True)])
labour_tax_id = fields.Many2many('account.tax',string='Labour Taxes',domain=['|', ('active', '=', False), ('active', '=', True)])
Run Code Online (Sandbox Code Playgroud)
在.xml文件中:
<field name="supply_tax_id" widget="many2many_tags" domain="[('type_tax_use','=','sale'),('company_id','=',parent.company_id)]" attrs="{'readonly': [('qty_invoiced', '>', 0)]}"/>
<field name="labour_tax_id" widget="many2many_tags" domain="[('type_tax_use','=','sale'),('company_id','=',parent.company_id)]" attrs="{'readonly': [('qty_invoiced', '>', 0)]}"/>
Run Code Online (Sandbox Code Playgroud)
虽然我尝试更改supply_tax_id
它,但是保存后supply_tax_id
,labour_tax_id
两者是相同的。我不知道它是如何相互连接的。我想要supply_tax_id
并且labour_tax_id
应该是不同的值,字段应该来自account.tax
。
请帮我找到解决问题的方法。谢谢大家的建议。
csv ×1
html-table ×1
openerp ×1
postgresql ×1
python ×1
python-2.7 ×1
python-3.x ×1
virtualenv ×1