小编Shi*_*uku的帖子

TypeError:需要类似字节的对象,而不是python和CSV中的'str'

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)

在最后一行上方.

csv html-table beautifulsoup python-3.x

141
推荐指数
4
解决办法
16万
查看次数

'virtualenv'不被识别为内部或外部命令,可操作程序或批处理文件

在安装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'不被识别为内部或外部命令,可操作程序或批处理文件.

virtualenv python-2.7

19
推荐指数
8
解决办法
4万
查看次数

many2many字段都是相同的值吗?

我有以下代码:

在.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', '&gt;', 0)]}"/>
<field name="labour_tax_id" widget="many2many_tags" domain="[('type_tax_use','=','sale'),('company_id','=',parent.company_id)]" attrs="{'readonly': [('qty_invoiced', '&gt;', 0)]}"/>
Run Code Online (Sandbox Code Playgroud)

虽然我尝试更改supply_tax_id它,但是保存后supply_tax_idlabour_tax_id两者是相同的。我不知道它是如何相互连接的。我想要supply_tax_id并且labour_tax_id应该是不同的值,字段应该来自account.tax

请帮我找到解决问题的方法。谢谢大家的建议。

python postgresql openerp

2
推荐指数
1
解决办法
580
查看次数