到目前为止,我只是偶然发现并喜欢它.我有这个代码由主网站提供
import plotly.plotly as py
from plotly.graph_objs import *
trace0 = Scatter(
x=[1,2,3,4],
y=[10,15,13,17]
)
trace1 = Scatter(
x=[1,2,3,4],
y=[16,5,11,9]
)
data = Data([trace0, trace1])
unique_url = py.plot(data, filename='basic-line')
Run Code Online (Sandbox Code Playgroud)
我很好奇两件事:
1)当我运行此代码时,我的浏览器会自动弹出并向我显示图表.我想要的只是网址,以便我以后可以将其嵌入到html文件中.有没有办法关闭打开浏览器的功能并向我显示图表?
2)有没有办法摆脱'使用此数据播放'链接?
我已经梳理了所提供的文件,但在这两个问题上却空手而归.
我有这个火花程序,我会尝试将其限制在相关部分
# Split by delimiter ,
# If the file is in unicode, we need to convert each value to a float in order to be able to
# treat it as a number
points = sc.textFile(filename).map(lambda line: [float(x) for x in line.split(",")]).persist()
# start with K randomly selected points from the dataset
# A centroid cannot be an actual data point or else the distance measure between a point and
# that centroid will be zero. This leads to …Run Code Online (Sandbox Code Playgroud) 我正在使用plotly offline并且能够使用生成html文件
plotly.offline.plot({"data": data, "layout": layout})
Run Code Online (Sandbox Code Playgroud)
它很棒.图表生成正确,html文件保存到我当前的目录.
我想要的是,使用绘图离线,可以保存图像(.png,.jpg等)文件.我是在正确的轨道上吗?从这里我需要做什么?
time="2017-10-27T07:39:20Z" level=error msg="Can't add file /var/app/current/app/content_classifier/forest.pickle to tar: io: read/write on closed pipe"
time="2017-10-27T07:39:20Z" level=error msg="Can't close tar writer: io: read/write on closed pipe"
Failed to build Docker image aws_beanstalk/staging-app: tar writer: io: read/write on closed pipe"
Error response from daemon: Untar error on re-exec cmd: fork/exec /proc/self/exe: cannot allocate memory. Check snapshot logs for details. (Executor::NonZeroExitStatus)
Run Code Online (Sandbox Code Playgroud)
我在 django_app/content_classifer 对象中有一个 Pickle 对象。有一个类可以预测结果,并且在 celery 任务文件初始化时它正在初始化。
docker build 在给出标题中的错误消息后一直失败。
我的理解是pythonanywhere支持无头的Firefox浏览器但你需要
from pyvirtualdisplay import Display
Run Code Online (Sandbox Code Playgroud)
所以你可以使用连接
with Display():
while True:
try:
driver = webdriver.Firefox()
break
except:
time.sleep(3)
Run Code Online (Sandbox Code Playgroud)
我连接得很好.但是,在我开始使用驱动程序之后
with Display():
while True:
try:
driver = webdriver.Firefox()
break
except:
time.sleep(3)
wb=load_workbook(r'/home/hoozits728/mutual_fund_tracker/Mutual_Fund_Tracker.xlsx')
ws=wb.get_sheet_by_name('Tactical')
for i in range(3, ws.max_row+1):
if ws.cell(row=i,column=2).value is not None:
driver.get('https://finance.yahoo.com/quote/' + ws.cell(row=i,column=2).value + '/performance?ltr=1')
oneyear=driver.find_element_by_css_selector('#Col1-0-Performance-Proxy > section > div:nth-child(2) > div > div:nth-child(5) > span:nth-child(2)').text
threeyear=driver.find_element_by_css_selector('#Col1-0-Performance-Proxy > section > div:nth-of-type(2) > div > div:nth-of-type(6) > span:nth-of-type(2)').text
fiveyear=driver.find_element_by_css_selector('#Col1-0-Performance-Proxy > section > div:nth-of-type(2) > div > div:nth-of-type(7) > span:nth-of-type(2)').text
ws.cell(row=i,column=10).value=oneyear …Run Code Online (Sandbox Code Playgroud) python selenium pythonanywhere selenium-webdriver python-3.5
我有兴趣在python中读取一个pgm文件作为数字文件/矩阵
现在我打开文件
f = open('/home/matthew/NCM/mdb001.pgm', 'rb')
Run Code Online (Sandbox Code Playgroud)
当我读到第一行时,它看起来像预期的那样
r.readline()
Run Code Online (Sandbox Code Playgroud)
产生
'P5\n'
Run Code Online (Sandbox Code Playgroud)
而下一行很好
'1024 1024\n'
Run Code Online (Sandbox Code Playgroud)
而下一个
'255\n'
Run Code Online (Sandbox Code Playgroud)
但后来我得到了一系列的胡言乱语.它看起来像一些十六进制值与其他东西混合在一起.
我不想将文件视为图片图片,我只想以这种格式看到它.
那里有与此类似的问题,但我找不到解决我问题的任何方法。
我正在执行django项目,并进行了数据库更改,并且想要将数据库更改迁移到生产环境。所以我跑
python manage.py migrate
Run Code Online (Sandbox Code Playgroud)
但是我收到这个错误
OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: NO)")
Run Code Online (Sandbox Code Playgroud)
据我了解,我不一定具有运行迁移的权限,但我确实尝试过
grant all privileges on *.* to root@localhost identified by 'password' with grant option;
Run Code Online (Sandbox Code Playgroud)
及其不同的组合,但无济于事。
在我的local_settings.py中,
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'USER': 'root',
'PASSWORD': 'password',
'HOST': '127.0.0.1',
'NAME': 'stratinvnet',
},
}
Run Code Online (Sandbox Code Playgroud)
我已尝试更改127.0.0.1为localhost,但这似乎没有任何区别。我也尝试过从DATABASES对象中删除密码。
对于它的价值,这是我GRANTS在mysql中的表。
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*5FE8B16533FAE91D61522C9A6811F3F709147255' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO …Run Code Online (Sandbox Code Playgroud) 在使用 python 的 selenium 来抓取 bet365 时,我了解到我需要(成功)使用unDetected-chromedriver
直到几天前,这段代码还像魅力一样有效
import undetected_chromedriver as uc
driver = uc.Chrome()
driver.get('https://bet365.com')
Run Code Online (Sandbox Code Playgroud)
然而,现在,当使用这个时,我在浏览器中得到这个
我的页面永远不会返回。
最近 chrome 似乎已将我更新到版本 87,因此我尝试下载并使用为我的 chrome 版本推荐的最新 chromedriver。这并没有改变事情。
然后我决定恢复到以前的 chrome 版本并使用与该版本对应的 chromedriver。这也没有改变事情。
我还尝试更改我的视口并添加假用户代理。依然没有。
我在某处读到尝试这个选项
options=uc.ChromeOptions()
options.add_argument("--disable-backgrounding-occluded-windows")
Run Code Online (Sandbox Code Playgroud)
但我的问题仍然没有解决。
所以现在我在这里问:我可以做些什么来成功地使用bet365.com 进行操作undetected_chromedriver吗?
python selenium web-scraping python-3.x selenium-chromedriver
新的,并尝试学习python和django.我会切入正确的追逐.我正在阅读主站点上的django教程,我发现你可以在django中设置一个数据库,其类变量就像这里给出的那样
from django.db import models
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
Run Code Online (Sandbox Code Playgroud)
在本教程的后面,使用创建Poll对象
p = Poll(question="What's new?", pub_date=timezone.now())
Run Code Online (Sandbox Code Playgroud)
我的问题是:看起来字符串是使用命名参数传递的,但在类中,这些似乎是使用构造的对象models.那么django如何转换字符串"什么是新的?",成为一个问题对象?
我试图为我在下面定义的CurrentClient变量设置一个值,然后用它来计算它在一个范围内出现的次数.我不知道我在这里做错了什么.它给出了错误:"运行时错误9下标超出范围"的步骤,它将Sheet 2单元格A2中的值赋给Currentclient.
请帮忙.
Sub GetValue()
Dim ClientCnt As Integer
Dim CurrentClient As String
CurrentClient = Sheets("Sheet 2").Range("A2").Text
ClientCnt = Application.WorksheetFunction.CountIf(Range("A:A"), CurrentClient)
End Sub
Run Code Online (Sandbox Code Playgroud) 当不存在分隔符时,python split 函数返回什么?我认为它一定是一个包含一个元素的列表,即整个字符串。例如
s = "700"
parts = s.split(".")
Run Code Online (Sandbox Code Playgroud)
里面是什么parts[0]?是“700”吗?或者什么也没有?
我的个人测试,我所尝试过的,表明了这一点parts[0] = "700",但我想确定一下。
python ×9
django ×2
plotly ×2
selenium ×2
apache-spark ×1
bigdata ×1
celery ×1
celerybeat ×1
django-1.5 ×1
docker ×1
excel ×1
excel-vba ×1
file ×1
file-read ×1
html ×1
image ×1
linux ×1
mysql ×1
pgm ×1
pyspark ×1
python-2.7 ×1
python-3.5 ×1
python-3.x ×1
string ×1
vba ×1
web-scraping ×1