python大神帮忙看看,python3+selenium使用maximize_window最大化谷歌窗口报错
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python大神帮忙看看,python3+selenium使用maximize_window最大化谷歌窗口报错相关的知识,希望对你有一定的参考价值。
报错信息
Traceback (most recent call last):
File "E:/各种资料/python资料/operate/selenium+python.py", line 7, in <module>
driver.maximize_window()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 551, in maximize_window
self.execute(command, "windowHandle": "current")
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot get automation extension
python程序执行报错,请大神帮忙看下
# -*- coding: cp936 -*-
#--conding: -utf-8--
#给出三角形的三条边长,判断该三角形的形状,并计算面积
_metaclass_=type
class sanJiaoXing:
mianji=0
p=0
def init(self):
a=int(raw_input("a="))
b=int(raw_input("b="))
c=int(raw_input("c="))
if a+b<c or a+c<b or b+c<a:
print "两边之和小于第三边,无法构成三角形"
elif a==b==c:
print "这个三角形是等边三角形"
elif a==b!=c or b==c!=a or a==c!=b:
print "这个三角形是等腰三角形"
elif a*a+b*b==c*c or a*a+c*c==b*b or b*b+c*c==a*a:
print"这个是直角三角形"
else:
print"这个是一般三角形"
def MianJi(self):
from math import sqrt
p=(a+b+c)/2
mianji=sqrt(p*(p-a)*(p-b)*(p-c))
print "三角形的面积为:%s" % mianji
test=sanJiaoXing()
test.init()
test.MianJi()
错误信息
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\python1\三角形判断.py", line 32, in <module>
test.MianJi()
File "C:\Users\Administrator\Desktop\python1\三角形判断.py", line 26, in MianJi
p=(a+b+c)/2
NameError: global name 'a' is not defined
>>>
支持xhkczxzz.
再来一个:
#!/usr/bin/env python# coding: utf-8
#
# filename: triangle.py
# date: Feb., 2014
# author: Tim Wang
class Triangle(object):
def __init__(self, a, b, c):
self.lines = sorted([a, b, c])
if self.lines[0] + self.lines[1] <= self.lines[2]:
raise TypeError
def category(self):
if self.lines[0] == self.lines[1] == self.lines[2]:
return u"等边三角形"
category = u""
if (self.lines[0] == self.lines[1] or
self.lines[1] == self.lines[2]):
category += u"等腰"
A = self.lines[0] ** 2 + self.lines[1] ** 2
B = self.lines[2] ** 2
if A == B:
category += u"直角"
elif A > B:
category += u"锐角"
else:
category += u"钝角"
return category + u"三角形"
def perimeter(self):
"""周长"""
return self.lines[0] + self.lines[1] + self.lines[2]
def area(self):
"""面积(海伦公式)"""
p = sum(self.lines)/2.
return (p
* (p - self.lines[0])
* (p - self.lines[1])
* (p - self.lines[2])
) ** .5
def R(self):
"""外接圆半径"""
return (self.lines[0]
* self.lines[1]
* self.lines[2] ) / (4 * self.area())
tr = Triangle(3, 4, 5)
print tr.perimeter()
print tr.area()
print tr.R()
print tr.category().encode("utf-8") 参考技术A 把a\b\c改为:
self.a
self.b
self.c追问
多谢,多谢,
在这边的时候是不是应该添加break啊,
if a+b<c or a+c<b or b+c<a:
print "两边之和小于第三边,无法构成三角形"
我输入三边为1,2,1时,仍执行了下面的求面积的方法了。
可是我加了break会有问题,求大神再次帮忙看下。多谢多谢
mianji=p=0
issanJiaoXing=False
def __init__(self): #######
self.a=int(raw_input("a="))
self.b=int(raw_input("b="))
self.c=int(raw_input("c="))
self.isSanjiaoxing(self.a,self.b,self.c)
def isSanjiaoxing(self,a,b,c): #######
if self.a+self.b<=self.c or self.a+self.c<=self.b or self.b+self.c<=self.a:
print "非三角形"
self.issanJiaoXing=False ###
return
elif self.a==self.b==self.c:
print "等边"
elif self.a==self.b!=self.c or self.b==self.c!=self.a or self.a==self.c!=self.b:
print "等腰"
elif self.a*self.a+self.b*self.b==self.c*self.c or self.a*self.a+self.c*self.c==self.b*self.b or self.b*self.b+self.c*self.c==self.a*self.a:
print"直角"
else:
print"一般"
self.issanJiaoXing=True ###
def MianJi(self):
……
p=(self.a+self.b+self.c)/2.0 ######
……
test=sanJiaoXing()
test.MianJi()本回答被提问者采纳
以上是关于python大神帮忙看看,python3+selenium使用maximize_window最大化谷歌窗口报错的主要内容,如果未能解决你的问题,请参考以下文章
初学PYTHON数据抓取,有一段代码就是运行不了。有知道的大神帮帮忙,谢谢
xssfcellstyle 设置背景色问题,哪位大神帮忙看看