python的问题执行.py 提示nameError 5C

图片说明
执行hello.py里面只是print‘hello’一行代码,这是什么问题引起的希望知道的帮忙解决一下谢谢各位前辈

25个回答

图片说明直接执行命令hello.py就行了,然后注意下目录对不对

lpl0620
自强之路 谢谢指导呀是这个问题了可以执行啦
2 年多之前 回复

你的文件是不是有不可见的字符?

执行hello.py里面只是print‘hello’一行代码,

spython hello.py

 print‘hello’
->
print 'hello'

你的标点是全角的。

想要在cmd窗口執行py文件,有兩種方法:(1)cd 切換到py文件所在的文件夾python hello.py;(2)python hello.py的絕對路徑

脚本代码改下 print ('hello')

执行hello.py里面只是print‘hello

python执行py文件,的方法有很多,最简单的就是在进入文件所在目录,然后输入python hello.py 这样就能运行hello.py这个文件了
图片说明

共25条数据 1 3 尾页
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
执行pipenv run python manage.py runserver 0.0.0.0:8000系统检查报错name 'blog' is not defined,求解怎么解决?

File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner self.run() File "/usr/lib/python3.6/threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "/home/jango/django-venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 54, in wrapper fn(*args, **kwargs) File "/home/jango/django-venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run self.check(display_num_errors=True) File "/home/jango/django-venv/lib/python3.6/site-packages/django/core/management/base.py", line 390, in check include_deployment_checks=include_deployment_checks, File "/home/jango/django-venv/lib/python3.6/site-packages/django/core/management/base.py", line 377, in _run_checks return checks.run_checks(**kwargs) File "/home/jango/django-venv/lib/python3.6/site-packages/django/core/checks/registry.py", line 72, in run_checks new_errors = check(app_configs=app_configs) File "/home/jango/django-venv/lib/python3.6/site-packages/django/core/checks/urls.py", line 13, in check_url_config return check_resolver(resolver) File "/home/jango/django-venv/lib/python3.6/site-packages/django/core/checks/urls.py", line 23, in check_resolver return check_method() File "/home/jango/django-venv/lib/python3.6/site-packages/django/urls/resolvers.py", line 398, in check for pattern in self.url_patterns: File "/home/jango/django-venv/lib/python3.6/site-packages/django/utils/functional.py", line 80, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/home/jango/django-venv/lib/python3.6/site-packages/django/urls/resolvers.py", line 579, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/home/jango/django-venv/lib/python3.6/site-packages/django/utils/functional.py", line 80, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/home/jango/django-venv/lib/python3.6/site-packages/django/urls/resolvers.py", line 572, in urlconf_module return import_module(self.urlconf_name) File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/home/jango/django-one/blogproject/blogproject/urls.py", line 7, in <module> path('', include('blog.urls')), File "/home/jango/django-venv/lib/python3.6/site-packages/django/urls/conf.py", line 34, in include urlconf_module = import_module(urlconf_module) File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/home/jango/django-one/blogproject/blog/urls.py", line 3, in <module> from . import views File "/home/jango/django-one/blogproject/blog/views.py", line 1, in <module> blog/views.py NameError: name 'blog' is not defined

Python执行时,re.search报错,求原因及解决方案。

执行以下代码时,re.search报错。按理说我代码没啥问题,不知道怎么回事。求大神帮助! ``` hand=open("regex_sum_42.txt") for line in hand: line=line.rstrip() if re.search("Why",line): print(line) ``` 执行结果: Traceback (most recent call last): File "task1.py", line 4, in <module> if re.search("Why",line): NameError: name 're' is not defined

tensorflow上的一个案例mnist,运行出错,求问

from tensorflow.examples.tutorials.mnist import input_data import tensorflow as tf # Import data mnist = input_data.read_data_sets('MNIST_data/', one_hot=True) # Create the model x = tf.placeholder(tf.float32, [None, 784]) W = tf.Variable(tf.zeros([784, 10])) b = tf.Variable(tf.zeros([10])) y = tf.matmul(x, W) + b # Define loss and optimizer y_ = tf.placeholder(tf.float32, [None, 10]) # The raw formulation of cross-entropy, # # tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(tf.nn.softmax(y)), # reduction_indices=[1])) # # can be numerically unstable. # # So here we use tf.nn.softmax_cross_entropy_with_logits on the raw # outputs of 'y', and then average across the batch. cross_entropy = tf.reduce_mean( tf.nn.softmax_cross_entropy_with_logits(labels=y_, logits=y)) train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy) sess = tf.InteractiveSession() tf.global_variables_initializer().run() # Train for _ in range(1000): batch_xs, batch_ys = mnist.train.next_batch(100) sess.run(train_step, feed_dict={x: batch_xs, y_: batch_ys}) # Test trained model correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1)) accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32)) print(sess.run(accuracy, feed_dict={x: mnist.test.images, y_: mnist.test.labels})) 错误如下: Traceback (most recent call last): File "/home/linbinghui/文档/pycode/Text-1.py", line 5, in <module> mnist = input_data.read_data_sets('MNIST_data/', one_hot=True) File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py", line 189, in read_data_sets local_file = maybe_download(TEST_IMAGES, train_dir, SOURCE_URL + TEST_IMAGES) File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/datasets/base.py", line 81, in m aybe_download urllib.request.urlretrieve(source_url, temp_file_name) File "/usr/lib/python2.7/urllib.py", line 98, in urlretrieve return opener.retrieve(url, filename, reporthook, data) File "/usr/lib/python2.7/urllib.py", line 245, in retrieve fp = self.open(url, data) File "/usr/lib/python2.7/urllib.py", line 213, in open return getattr(self, name)(url) File "/usr/lib/python2.7/urllib.py", line 364, in open_http return self.http_error(url, fp, errcode, errmsg, headers) File "/usr/lib/python2.7/urllib.py", line 377, in http_error result = method(url, fp, errcode, errmsg, headers) File "/usr/lib/python2.7/urllib.py", line 642, in http_error_302 headers, data) File "/usr/lib/python2.7/urllib.py", line 669, in redirect_internal return self.open(newurl) File "/usr/lib/python2.7/urllib.py", line 213, in open return getattr(self, name)(url) File "/usr/lib/python2.7/urllib.py", line 350, in open_http h.endheaders(data) File "/usr/lib/python2.7/httplib.py", line 1053, in endheaders self._send_output(message_body) File "/usr/lib/python2.7/httplib.py", line 897, in _send_output self.send(msg) File "/usr/lib/python2.7/httplib.py", line 859, in send self.connect() File "/usr/lib/python2.7/httplib.py", line 836, in connect self.timeout, self.source_address) File "/usr/lib/python2.7/socket.py", line 575, in create_connection raise err IOError: [Errno socket error] [Errno 111] Connection refused

想要在一个.py里调用另一个.py但是有错?

主程序如下,num想给图片编号,但是调用有问题 ``` # -*- coding: UTF-8 -*- #!/usr/bin/env python #前进1m,画边长( 0.6 )m的五边形 import rospy from geometry_msgs.msg import Twist from math import radians import trying class ROUTE(): count = 0 num = 0 def __init__(self): # 初始化节点 rospy.init_node('route', anonymous=True) # ctrl + c退出 rospy.on_shutdown(self.shutdown) self.cmd_vel = rospy.Publisher('cmd_vel_mux/input/navi', Twist, queue_size=10) # 5 HZ更新频率 r = rospy.Rate(5); # 两个不同的Twist,转,直走 # 0.5 m/s 前进 move_cmd = Twist() move_cmd.linear.x = 0.2 #旋转18 deg/s turn_cmd = Twist() turn_cmd.linear.x = 0 turn_cmd.angular.z = radians(18); # 前进1M rospy.loginfo("我在找位置ing") for x in range(0,25): self.cmd_vel.publish(move_cmd) r.sleep() while not rospy.is_shutdown(): #来拍照啊 rospy.loginfo("123,茄子!") for x in range(0,15): trying.TakePhoto( num ) num = num + 1 r.sleep() #转54度 rospy.loginfo("好丑~我换个角度哈~") for x in range(0,15): self.cmd_vel.publish(turn_cmd) r.sleep() # 前进0.5M rospy.loginfo("我在找下一个位置ing") for x in range(0,15): self.cmd_vel.publish(move_cmd) r.sleep() # 转234度 rospy.loginfo("就在这里拍啦!") for x in range(0,65): self.cmd_vel.publish(turn_cmd) r.sleep() count = count + 1 if(count == 5): count = 0 if(count == 0): rospy.loginfo("是不是该结束了?好累哦~~") if( num > 7): rospy.loginfo("都要没电啦……停下来吧……机器人也很累呀!") def shutdown(self): # 停啦 rospy.loginfo("停啦,么么哒,记得充电~~") self.cmd_vel.publish(Twist()) rospy.sleep(1) if __name__ == '__main__': try: ROUTE() except: rospy.loginfo("Bye~~") rospy.sleep(1) ``` 调用的trying.py如下: ``` # -*- coding: UTF-8 -*- #!/usr/bin/env python from __future__ import print_function import sys import rospy import cv2 from std_msgs.msg import String from sensor_msgs.msg import Image from cv_bridge import CvBridge, CvBridgeError class TakePhoto ( num ): def __init__(self): self.bridge = CvBridge() self.image_received = False # Connect image topic img_topic = "/camera/rgb/image_raw" self.image_sub = rospy.Subscriber(img_topic, Image, self.callback) # Allow up to one second to connection rospy.sleep(1) def callback(self, data): # Convert image to OpenCV format try: cv_image = self.bridge.imgmsg_to_cv2(data, "bgr8") except CvBridgeError as e: print(e) self.image_received = True self.image = cv_image def take_picture(self, img_title): if self.image_received: # Save an image cv2.imwrite(img_title, self.image) return True else: return False # Initialize rospy.init_node('take_photo', anonymous=False) camera = TakePhoto() # Take a photo # Use '_image_title' parameter from command line # Default value is 'photo.jpg' img_title = rospy.get_param('~image_title', num+'.jpg') if camera.take_picture(img_title): rospy.loginfo("保存啦 " + img_title) else: rospy.loginfo("没有吧……") # Sleep to give the last log messages time to be sent rospy.sleep(1) ``` 报错: Traceback (most recent call last): File "route.py", line 10, in <module> import trying File "/home/hazel/helloworld/turtlebot/trying.py", line 13, in <module> class TakePhoto ( num ): NameError: name 'num' is not defined 自己感觉没有错……前两次都是缩进的问题,现在专门全部改成了Tab键,就算吧num全部删掉,它也不调用直接退出了,我觉得是函数调用的问题

yolo3 darknet.py问题

我用darknetAB https://github.com/AlexeyAB/darknet 编译gpu版本后生成darknet.py文件 然后我也编译了yolo_cpp_dll.sln文件 生成dll文件 然后运行darknet.py文件 不显示图片 异常退出 ![图片说明](https://img-ask.csdn.net/upload/201911/02/1572688446_628910.png) 百度了这个问题 有人说要换python3.5版本 我也尝试了 但是也是不行 不会显示图片。请问各位大佬到底怎么解决??急!!!谢谢!!! ``` #!python3 """ Python 3 wrapper for identifying objects in images Requires DLL compilation Both the GPU and no-GPU version should be compiled; the no-GPU version should be renamed "yolo_cpp_dll_nogpu.dll". On a GPU system, you can force CPU evaluation by any of: - Set global variable DARKNET_FORCE_CPU to True - Set environment variable CUDA_VISIBLE_DEVICES to -1 - Set environment variable "FORCE_CPU" to "true" To use, either run performDetect() after import, or modify the end of this file. See the docstring of performDetect() for parameters. Directly viewing or returning bounding-boxed images requires scikit-image to be installed (`pip install scikit-image`) Original *nix 2.7: https://github.com/pjreddie/darknet/blob/0f110834f4e18b30d5f101bf8f1724c34b7b83db/python/darknet.py Windows Python 2.7 version: https://github.com/AlexeyAB/darknet/blob/fc496d52bf22a0bb257300d3c79be9cd80e722cb/build/darknet/x64/darknet.py @author: Philip Kahn @date: 20180503 """ #pylint: disable=R, W0401, W0614, W0703 from ctypes import * import math import random import os def sample(probs): s = sum(probs) probs = [a/s for a in probs] r = random.uniform(0, 1) for i in range(len(probs)): r = r - probs[i] if r <= 0: return i return len(probs)-1 def c_array(ctype, values): arr = (ctype*len(values))() arr[:] = values return arr class BOX(Structure): _fields_ = [("x", c_float), ("y", c_float), ("w", c_float), ("h", c_float)] class DETECTION(Structure): _fields_ = [("bbox", BOX), ("classes", c_int), ("prob", POINTER(c_float)), ("mask", POINTER(c_float)), ("objectness", c_float), ("sort_class", c_int)] class IMAGE(Structure): _fields_ = [("w", c_int), ("h", c_int), ("c", c_int), ("data", POINTER(c_float))] class METADATA(Structure): _fields_ = [("classes", c_int), ("names", POINTER(c_char_p))] #lib = CDLL("/home/pjreddie/documents/darknet/libdarknet.so", RTLD_GLOBAL) #lib = CDLL("libdarknet.so", RTLD_GLOBAL) hasGPU = True if os.name == "nt": cwd = os.path.dirname(__file__) os.environ['PATH'] = cwd + ';' + os.environ['PATH'] winGPUdll = os.path.join(cwd, "yolo_cpp_dll.dll") winNoGPUdll = os.path.join(cwd, "yolo_cpp_dll_nogpu.dll") envKeys = list() for k, v in os.environ.items(): envKeys.append(k) try: try: tmp = os.environ["FORCE_CPU"].lower() if tmp in ["1", "true", "yes", "on"]: raise ValueError("ForceCPU") else: print("Flag value '"+tmp+"' not forcing CPU mode") except KeyError: # We never set the flag if 'CUDA_VISIBLE_DEVICES' in envKeys: if int(os.environ['CUDA_VISIBLE_DEVICES']) < 0: raise ValueError("ForceCPU") try: global DARKNET_FORCE_CPU if DARKNET_FORCE_CPU: raise ValueError("ForceCPU") except NameError: pass # print(os.environ.keys()) # print("FORCE_CPU flag undefined, proceeding with GPU") if not os.path.exists(winGPUdll): raise ValueError("NoDLL") lib = CDLL(winGPUdll, RTLD_GLOBAL) except (KeyError, ValueError): hasGPU = False if os.path.exists(winNoGPUdll): lib = CDLL(winNoGPUdll, RTLD_GLOBAL) print("Notice: CPU-only mode") else: # Try the other way, in case no_gpu was # compile but not renamed lib = CDLL(winGPUdll, RTLD_GLOBAL) print("Environment variables indicated a CPU run, but we didn't find `"+winNoGPUdll+"`. Trying a GPU run anyway.") else: lib = CDLL("./libdarknet.so", RTLD_GLOBAL) lib.network_width.argtypes = [c_void_p] lib.network_width.restype = c_int lib.network_height.argtypes = [c_void_p] lib.network_height.restype = c_int copy_image_from_bytes = lib.copy_image_from_bytes copy_image_from_bytes.argtypes = [IMAGE,c_char_p] def network_width(net): return lib.network_width(net) def network_height(net): return lib.network_height(net) predict = lib.network_predict_ptr predict.argtypes = [c_void_p, POINTER(c_float)] predict.restype = POINTER(c_float) if hasGPU: set_gpu = lib.cuda_set_device set_gpu.argtypes = [c_int] make_image = lib.make_image make_image.argtypes = [c_int, c_int, c_int] make_image.restype = IMAGE get_network_boxes = lib.get_network_boxes get_network_boxes.argtypes = [c_void_p, c_int, c_int, c_float, c_float, POINTER(c_int), c_int, POINTER(c_int), c_int] get_network_boxes.restype = POINTER(DETECTION) make_network_boxes = lib.make_network_boxes make_network_boxes.argtypes = [c_void_p] make_network_boxes.restype = POINTER(DETECTION) free_detections = lib.free_detections free_detections.argtypes = [POINTER(DETECTION), c_int] free_ptrs = lib.free_ptrs free_ptrs.argtypes = [POINTER(c_void_p), c_int] network_predict = lib.network_predict_ptr network_predict.argtypes = [c_void_p, POINTER(c_float)] reset_rnn = lib.reset_rnn reset_rnn.argtypes = [c_void_p] load_net = lib.load_network load_net.argtypes = [c_char_p, c_char_p, c_int] load_net.restype = c_void_p load_net_custom = lib.load_network_custom load_net_custom.argtypes = [c_char_p, c_char_p, c_int, c_int] load_net_custom.restype = c_void_p do_nms_obj = lib.do_nms_obj do_nms_obj.argtypes = [POINTER(DETECTION), c_int, c_int, c_float] do_nms_sort = lib.do_nms_sort do_nms_sort.argtypes = [POINTER(DETECTION), c_int, c_int, c_float] free_image = lib.free_image free_image.argtypes = [IMAGE] letterbox_image = lib.letterbox_image letterbox_image.argtypes = [IMAGE, c_int, c_int] letterbox_image.restype = IMAGE load_meta = lib.get_metadata lib.get_metadata.argtypes = [c_char_p] lib.get_metadata.restype = METADATA load_image = lib.load_image_color load_image.argtypes = [c_char_p, c_int, c_int] load_image.restype = IMAGE rgbgr_image = lib.rgbgr_image rgbgr_image.argtypes = [IMAGE] predict_image = lib.network_predict_image predict_image.argtypes = [c_void_p, IMAGE] predict_image.restype = POINTER(c_float) predict_image_letterbox = lib.network_predict_image_letterbox predict_image_letterbox.argtypes = [c_void_p, IMAGE] predict_image_letterbox.restype = POINTER(c_float) def array_to_image(arr): import numpy as np # need to return old values to avoid python freeing memory arr = arr.transpose(2,0,1) c = arr.shape[0] h = arr.shape[1] w = arr.shape[2] arr = np.ascontiguousarray(arr.flat, dtype=np.float32) / 255.0 data = arr.ctypes.data_as(POINTER(c_float)) im = IMAGE(w,h,c,data) return im, arr def classify(net, meta, im): out = predict_image(net, im) res = [] for i in range(meta.classes): if altNames is None: nameTag = meta.names[i] else: nameTag = altNames[i] res.append((nameTag, out[i])) res = sorted(res, key=lambda x: -x[1]) return res def detect(net, meta, image, thresh=.5, hier_thresh=.5, nms=.45, debug= False): """ Performs the meat of the detection """ #pylint: disable= C0321 im = load_image(image, 0, 0) if debug: print("Loaded image") ret = detect_image(net, meta, im, thresh, hier_thresh, nms, debug) free_image(im) if debug: print("freed image") return ret def detect_image(net, meta, im, thresh=.5, hier_thresh=.5, nms=.45, debug= False): #import cv2 #custom_image_bgr = cv2.imread(image) # use: detect(,,imagePath,) #custom_image = cv2.cvtColor(custom_image_bgr, cv2.COLOR_BGR2RGB) #custom_image = cv2.resize(custom_image,(lib.network_width(net), lib.network_height(net)), interpolation = cv2.INTER_LINEAR) #import scipy.misc #custom_image = scipy.misc.imread(image) #im, arr = array_to_image(custom_image) # you should comment line below: free_image(im) num = c_int(0) if debug: print("Assigned num") pnum = pointer(num) if debug: print("Assigned pnum") predict_image(net, im) letter_box = 0 #predict_image_letterbox(net, im) #letter_box = 1 if debug: print("did prediction") # dets = get_network_boxes(net, custom_image_bgr.shape[1], custom_image_bgr.shape[0], thresh, hier_thresh, None, 0, pnum, letter_box) # OpenCV dets = get_network_boxes(net, im.w, im.h, thresh, hier_thresh, None, 0, pnum, letter_box) if debug: print("Got dets") num = pnum[0] if debug: print("got zeroth index of pnum") if nms: do_nms_sort(dets, num, meta.classes, nms) if debug: print("did sort") res = [] if debug: print("about to range") for j in range(num): if debug: print("Ranging on "+str(j)+" of "+str(num)) if debug: print("Classes: "+str(meta), meta.classes, meta.names) for i in range(meta.classes): if debug: print("Class-ranging on "+str(i)+" of "+str(meta.classes)+"= "+str(dets[j].prob[i])) if dets[j].prob[i] > 0: b = dets[j].bbox if altNames is None: nameTag = meta.names[i] else: nameTag = altNames[i] if debug: print("Got bbox", b) print(nameTag) print(dets[j].prob[i]) print((b.x, b.y, b.w, b.h)) res.append((nameTag, dets[j].prob[i], (b.x, b.y, b.w, b.h))) if debug: print("did range") res = sorted(res, key=lambda x: -x[1]) if debug: print("did sort") free_detections(dets, num) if debug: print("freed detections") return res netMain = None metaMain = None altNames = None def performDetect(imagePath="data/dog.jpg", thresh= 0.25, configPath = "./cfg/yolov3.cfg", weightPath = "yolov3.weights", metaPath= "./cfg/coco.data", showImage= True, makeImageOnly = False, initOnly= False): """ Convenience function to handle the detection and returns of objects. Displaying bounding boxes requires libraries scikit-image and numpy Parameters ---------------- imagePath: str Path to the image to evaluate. Raises ValueError if not found thresh: float (default= 0.25) The detection threshold configPath: str Path to the configuration file. Raises ValueError if not found weightPath: str Path to the weights file. Raises ValueError if not found metaPath: str Path to the data file. Raises ValueError if not found showImage: bool (default= True) Compute (and show) bounding boxes. Changes return. makeImageOnly: bool (default= False) If showImage is True, this won't actually *show* the image, but will create the array and return it. initOnly: bool (default= False) Only initialize globals. Don't actually run a prediction. Returns ---------------------- When showImage is False, list of tuples like ('obj_label', confidence, (bounding_box_x_px, bounding_box_y_px, bounding_box_width_px, bounding_box_height_px)) The X and Y coordinates are from the center of the bounding box. Subtract half the width or height to get the lower corner. Otherwise, a dict with { "detections": as above "image": a numpy array representing an image, compatible with scikit-image "caption": an image caption } """ # Import the global variables. This lets us instance Darknet once, then just call performDetect() again without instancing again global metaMain, netMain, altNames #pylint: disable=W0603 assert 0 < thresh < 1, "Threshold should be a float between zero and one (non-inclusive)" if not os.path.exists(configPath): raise ValueError("Invalid config path `"+os.path.abspath(configPath)+"`") if not os.path.exists(weightPath): raise ValueError("Invalid weight path `"+os.path.abspath(weightPath)+"`") if not os.path.exists(metaPath): raise ValueError("Invalid data file path `"+os.path.abspath(metaPath)+"`") if netMain is None: netMain = load_net_custom(configPath.encode("ascii"), weightPath.encode("ascii"), 0, 1) # batch size = 1 if metaMain is None: metaMain = load_meta(metaPath.encode("ascii")) if altNames is None: # In Python 3, the metafile default access craps out on Windows (but not Linux) # Read the names file and create a list to feed to detect try: with open(metaPath) as metaFH: metaContents = metaFH.read() import re match = re.search("names *= *(.*)$", metaContents, re.IGNORECASE | re.MULTILINE) if match: result = match.group(1) else: result = None try: if os.path.exists(result): with open(result) as namesFH: namesList = namesFH.read().strip().split("\n") altNames = [x.strip() for x in namesList] except TypeError: pass except Exception: pass if initOnly: print("Initialized detector") return None if not os.path.exists(imagePath): raise ValueError("Invalid image path `"+os.path.abspath(imagePath)+"`") # Do the detection #detections = detect(netMain, metaMain, imagePath, thresh) # if is used cv2.imread(image) detections = detect(netMain, metaMain, imagePath.encode("ascii"), thresh) if showImage: try: from skimage import io, draw import numpy as np image = io.imread(imagePath) print("*** "+str(len(detections))+" Results, color coded by confidence ***") imcaption = [] for detection in detections: label = detection[0] confidence = detection[1] pstring = label+": "+str(np.rint(100 * confidence))+"%" imcaption.append(pstring) print(pstring) bounds = detection[2] shape = image.shape # x = shape[1] # xExtent = int(x * bounds[2] / 100) # y = shape[0] # yExtent = int(y * bounds[3] / 100) yExtent = int(bounds[3]) xEntent = int(bounds[2]) # Coordinates are around the center xCoord = int(bounds[0] - bounds[2]/2) yCoord = int(bounds[1] - bounds[3]/2) boundingBox = [ [xCoord, yCoord], [xCoord, yCoord + yExtent], [xCoord + xEntent, yCoord + yExtent], [xCoord + xEntent, yCoord] ] # Wiggle it around to make a 3px border rr, cc = draw.polygon_perimeter([x[1] for x in boundingBox], [x[0] for x in boundingBox], shape= shape) rr2, cc2 = draw.polygon_perimeter([x[1] + 1 for x in boundingBox], [x[0] for x in boundingBox], shape= shape) rr3, cc3 = draw.polygon_perimeter([x[1] - 1 for x in boundingBox], [x[0] for x in boundingBox], shape= shape) rr4, cc4 = draw.polygon_perimeter([x[1] for x in boundingBox], [x[0] + 1 for x in boundingBox], shape= shape) rr5, cc5 = draw.polygon_perimeter([x[1] for x in boundingBox], [x[0] - 1 for x in boundingBox], shape= shape) boxColor = (int(255 * (1 - (confidence ** 2))), int(255 * (confidence ** 2)), 0) draw.set_color(image, (rr, cc), boxColor, alpha= 0.8) draw.set_color(image, (rr2, cc2), boxColor, alpha= 0.8) draw.set_color(image, (rr3, cc3), boxColor, alpha= 0.8) draw.set_color(image, (rr4, cc4), boxColor, alpha= 0.8) draw.set_color(image, (rr5, cc5), boxColor, alpha= 0.8) if not makeImageOnly: io.imshow(image) io.show() detections = { "detections": detections, "image": image, "caption": "\n<br/>".join(imcaption) } except Exception as e: print("Unable to show image: "+str(e)) return detections if __name__ == "__main__": print(performDetect()) ```

python报错问题nameerror

nameerror:name GrackGeetest is not defined 查看了程序没有任何的错误,单词也没有拼写错误,GrackGeetest名字就是类名,没有任何问题 还有其他解决问题吗?

python,url抓取问题(出现NameError)

def get_page(url): try: import urllib return urllib.urlopen(url).read() except: return '' def get_next_traget(page): global url page=get_page(url) start_link=page.find('<a href=') if start_link==-1: return None,0 else: start_quole=page.find('"',start_link) end_quote=page.find('"',start_quole+1) url=page[start_quole+1:end_quote] return url,end_quote def print_all_links(page): while True: url,endpos=get_next_traget(page) if url: print(url) page=page[endpos:] else: break print_all_links(get_page('https://www.baidu.com/')) pycharm上显示 File "F:/learning/0001/尝试.py", line 29, in <module> print_all_links(get_page('https://www.baidu.com/')) File "F:/learning/0001/尝试.py", line 22, in print_all_links url,endpos=get_next_traget(page) File "F:/learning/0001/尝试.py", line 10, in get_next_traget page=get_page(url) NameError: name 'url' is not defined 不明白什么意思,该怎么修改

python方法中调用函数出错 NameError: name 'get_step' is not defined

![图片说明](https://img-ask.csdn.net/upload/201912/14/1576327738_596321.png) get_step()调用错误 不知为何 求解决!

我的py文件可以在python3.6.2上运行,但是却不能在终端上运行,不知道问题出在哪,请求大佬帮帮忙,谢谢。

``` #!/usr/bin/python """ Created on Fri Dec 7 20:27:44 2018 @author: 10748 """ import os import filetype import sys import tensorflow as tf def train(file): a_list = list() # change this as you see fit image_path = file # Read in the image_data image_data = tf.gfile.FastGFile(image_path, 'rb').read() # Loads label file, strips off carriage return label_lines = [line.rstrip() for line in tf.gfile.GFile("output_labels.txt")] # Unpersists graph from file with tf.gfile.FastGFile("output_graph.pb", 'rb') as f: graph_def = tf.GraphDef() graph_def.ParseFromString(f.read()) _ = tf.import_graph_def(graph_def, name='') with tf.Session() as sess: # Feed the image_data as input to the graph and get first prediction softmax_tensor = sess.graph.get_tensor_by_name('final_result:0') predictions = sess.run(softmax_tensor, \ {'DecodeJpeg/contents:0': image_data}) # Sort to show labels of first prediction in order of confidence top_k = predictions[0].argsort()[-len(predictions[0]):][::-1] for node_id in top_k: human_string = label_lines[node_id] score = predictions[0][node_id] a_list.append(human_string+'_score = '+str(score)) return a_list def file_type(file): try: b = filetype.guess(file) c = b.extension if c == 'jpg': return file except: return file_list = list() for root, dirs, files in os.walk(".", topdown=False): for name in files: file_list.append(os.path.join(name)) for i in range(len(file_list)): file_name = file_type(file_list[i]) if file_name == None: print('') else: a =train(file_name) for q in range (len(a)): print(a[q]) input('按下回车键退出') ``` 终端上显示: Traceback (most recent call last): File "D:\Anaconda3\envs\tensorflow-gpu\flow\data\train\TS.py", line 35, in <module> for q in range (len(a)): NameError: name 'a' is not defined

《pythno编程从入门到实践》18.2.2中makemigrations时出错是啥情况

Traceback (most recent call last): File "manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "/Users/taoyu/Desktop/learning_log/ll_env/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/Users/taoyu/Desktop/learning_log/ll_env/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute django.setup() File "/Users/taoyu/Desktop/learning_log/ll_env/lib/python3.7/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/Users/taoyu/Desktop/learning_log/ll_env/lib/python3.7/site-packages/django/apps/registry.py", line 112, in populate app_config.import_models() File "/Users/taoyu/Desktop/learning_log/ll_env/lib/python3.7/site-packages/django/apps/config.py", line 198, in import_models self.models_module = import_module(models_module_name) File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/Users/taoyu/Desktop/learning_log/learning_logs/models.py", line 5, in <module> class Topics(models.Model): File "/Users/taoyu/Desktop/learning_log/learning_logs/models.py", line 8, in Topics date_added = models.DateTimeField(auto_now_add=Ture) NameError: name 'Ture' is not defined

python3调用Fdfs_client 出错

windows下使用 fdfs_client 上传文件 参考 https://www.cnblogs.com/kindleheart/p/10134502.html 已经用pip安装了fdfs_client 在用语句:client = Fdfs_client(r'C:\client.conf') 调用的时候报错: >>> client = Fdfs_client(r'client.conf') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\ProgramData\Anaconda3\lib\site-packages\fdfs_client\client.py", line 51, in __init__ self.tracker_pool = poolclass(**self.trackers) TypeError: type object argument after ** must be a mapping, not str 麻烦各位帮忙解答。 ![图片说明](https://img-ask.csdn.net/upload/201812/28/1545988262_317592.png)

做数据库迁移时提示 name 'String' is not defined

在做migrate的upgrade操作时提示 name 'String' is not defined这个问题,搞不懂问题出在哪 报错如下 ``` (venv) E:\python project\test1>python manage.py db upgrade INFO [alembic.runtime.migration] Context impl MySQLImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL. INFO [alembic.runtime.migration] Running upgrade 61ea10b5db1e -> ce1f8dd4a89a, empty message Traceback (most recent call last): File "manage.py", line 33, in <module> manager.run() File "E:\python project\test1\venv\lib\site-packages\flask_script\__init__.py", line 417, in run result = self.handle(argv[0], argv[1:]) File "E:\python project\test1\venv\lib\site-packages\flask_script\__init__.py", line 386, in handle res = handle(*args, **config) File "E:\python project\test1\venv\lib\site-packages\flask_script\commands.py", line 216, in __call__ return self.run(*args, **kwargs) File "E:\python project\test1\venv\lib\site-packages\flask_migrate\__init__.py", line 96, in wrapped f(*args, **kwargs) File "E:\python project\test1\venv\lib\site-packages\flask_migrate\__init__.py", line 271, in upgrade command.upgrade(config, revision, sql=sql, tag=tag) File "E:\python project\test1\venv\lib\site-packages\alembic\command.py", line 298, in upgrade script.run_env() File "E:\python project\test1\venv\lib\site-packages\alembic\script\base.py", line 489, in run_env util.load_python_file(self.dir, "env.py") File "E:\python project\test1\venv\lib\site-packages\alembic\util\pyfiles.py", line 98, in load_python_file module = load_module_py(module_id, path) File "E:\python project\test1\venv\lib\site-packages\alembic\util\compat.py", line 184, in load_module_py spec.loader.exec_module(module) File "<frozen importlib._bootstrap_external>", line 783, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "migrations\env.py", line 96, in <module> run_migrations_online() File "migrations\env.py", line 90, in run_migrations_online context.run_migrations() File "<string>", line 8, in run_migrations File "E:\python project\test1\venv\lib\site-packages\alembic\runtime\environment.py", line 846, in run_migrations self.get_context().run_migrations(**kw) File "E:\python project\test1\venv\lib\site-packages\alembic\runtime\migration.py", line 520, in run_migrations step.migration_fn(**kw) File "E:\python project\test1\migrations\versions\ce1f8dd4a89a_.py", line 25, in upgrade sa.Column('domainabbr', sa.String(length=String(length=2)), nullable=True), NameError: name 'String' is not defined ```

为啥会显示name error错误啊?

[Clang 6.0 (clang-600.0.57)] Type "help", "copyright", "credits" or "license" for more information. [evaluate elevation.py] update_elevation(THREE_BY_THREE_COPY, [1, 0], [1, 1], -2) Traceback (most recent call last): Python Shell, prompt 2, line 1 builtins.NameError: name 'THREE_BY_THREE_COPY' is not defined def update_elevation(elevation_map: List[List[int]], start: List[int], stop: List[int], delta: int) -> None: """Modify elevation map elevation_map so that the elevation of each cell between cells start and stop, inclusive, changes by amount delta. Precondition: elevation_map is a valid elevation map. start and stop are valid cells in elevation_map. start and stop are in the same row or column or both. If start and stop are in the same row, start's column <= stop's column. If start and stop are in the same column, start's row <= stop's row. elevation_map[i, j] + delta >= 1 for each cell [i, j] that will change. >>> THREE_BY_THREE_COPY = [[1, 2, 1], ... [4, 6, 5], ... [7, 8, 9]] >>> update_elevation(THREE_BY_THREE_COPY, [1, 0], [1, 1], -2) >>> THREE_BY_THREE_COPY [[1, 2, 1], [2, 4, 5], [7, 8, 9]] >>> FOUR_BY_FOUR_COPY = [[1, 2, 6, 5], ... [4, 5, 3, 2], ... [7, 9, 8, 1], ... [1, 2, 1, 4]] >>> update_elevation(FOUR_BY_FOUR_COPY, [1, 2], [3, 2], 1) >>> FOUR_BY_FOUR_COPY [[1, 2, 6, 5], [4, 5, 4, 2], [7, 9, 9, 1], [1, 2, 2, 4]] """ THREE_BY_THREE_COPY = [[1, 2, 1], ... [4, 6, 5], ... [7, 8, 9]] FOUR_BY_FOUR_COPY = [[1, 2, 6, 5], ... [4, 5, 3, 2], ... [7, 9, 8, 1], ... [1, 2, 1, 4]] if start[0]==stop[0]: for num in range(stop[1]-start[1]): elevation_map[start[0]][start[1+i]]=elevation_map[start[0]][start[1+i]]+delta else: for num in range(stop[0]-start[0]): elevation_map[start[0]][start[1+i]]=elevation_map[start[0+i]][start[1]]+delta

Lintcode name 'Solution' is not defined EXITCODE=1

题目是写一个用递归找到从1到N位的最大数字 比如N=2 返回[1,2,....99].下面是我写的代码,逻辑结果我认为是正确的, 但是提交时返回: File "Main.py", line 7, in solution = Solution() NameError: name 'Solution' is not defined EXITCODE=1。这跟我的程序哪里有什么关系么??真的很不解啊!另外我这里用list表示数字,结果比如99表示成了[9,9],有没有人知道该用什么数据结构合理的表示呢?代码如下: ``` class Solution: # @param n: An integer. # return : A list of integer storing 1 to the largest number with n digits. def numbersByRecursion(self, n): # write your code here if n <1: return None numList = [] for i in range(10): print i number =[] print number number.append(i) print 'number[0]= ',number self.setOnebyOne(numList, number,n,0) def setOnebyOne(self,numList,number,n,index): if index == n-1: print 'index = n-1',n-1,number numList.append(number) return numList print index,'setting',number for i in range(10): if i == 0: number.append(i) else: number[index+1] = i print number self.setOnebyOne(numList, number,n,index+1) '''这里如果是return则最里面的递归语句返回后接着执行的是return语句,函数就返回了,而不是返回上一层递归调用。 ''' ```

Python编程从入门到实践 第18章Django入门 第365页“添加主题”出错,找不出原因,求大神帮忙

电脑系统为64位的win7,python为64位的3.7.4版本,Django为2.2.4版本,学习第365页“添加主题”遇到了麻烦 ,自己摸索了很长时间,网上也搜索了很久还是没解决,求大神帮帮小白。 ![图片说明](https://img-ask.csdn.net/upload/201908/27/1566913286_833364.jpg) 在添加Chess主题时网页和终端里都报错,终端错误截图如下: ![图片说明](https://img-ask.csdn.net/upload/201908/27/1566912120_690258.png) 网页错误最前面的截图如下: ![图片说明](https://img-ask.csdn.net/upload/201908/27/1566912225_331720.png) 网页错误提示很长,下面这张是最后带提示的截图,我按照提示把settings.py文件里的DEBUG = False后,终端就退出了,再次运行python manage.py runserver终端也无法启动。 ![图片说明](https://img-ask.csdn.net/upload/201908/27/1566912555_34630.png) 仔细检查代码也没查出来,models.py,settings.py,admins.py代码如下: ![图片说明](https://img-ask.csdn.net/upload/201908/27/1566913232_687107.png) ![图片说明](https://img-ask.csdn.net/upload/201908/27/1566913242_373496.png) ![图片说明](https://img-ask.csdn.net/upload/201908/27/1566913253_641400.png)

关于json.load()里报错的问题:json.decoder.JSONDecodeError:

用python爬猫眼电影,代码和老师讲的一样的,但是出现了一些问题: ``` # -*- coding: utf-8 -*- from urllib import request import json def get_data(url): headers = { 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1' } req = request.Request(url, headers=headers) response = request.urlopen(req) if response.getcode() == 200: print(response.read()) return response.read() def parse_data(html): data = json.loads(html)['cmts'] print(data) if __name__ == '__main__': url = 'http://m.maoyan.com/mmdb/comments/movie/1203084.json?_v_=yes&offset=15&startTime=2018-09-01%2011%3A10%3A00' parse_data(get_data(url)) ``` 报错如下: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

菜鸟在win 10系统下装python 2.7.12后运行的疑惑

问题很菜,都不好意思上来问。 在学《简明 Python 教程 》。下载了python2 最新版,装完后,用Python GUI写了入门程序helloworld.py。在window的 command prompt输入 helloworld.py下运行正常,可是在Python(command line)输入helloworld.py不能运行,总出来错误 Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'helloworld' is not defined 是怎么回事? python没装好吗?可是在Python(command line)里输入print'hello',可以正确显示啊。难道Python(command line)下本身就不能运行python 文件,只可以一行一行运行?

QT调用Python,调用第三库不成功

如果python 中没有import matplotlib.pyplot as plt 这行代码 QT调用成功,如果python中有这行代码在debug下调用成功release下不成功 请问这是什么原因

python新手求助程序问题

各位大神好: 我在课本上抄了一段程序,想看看运行结果,运行时却报错,请帮忙查看是什么原因. 代码如下 ``` import sqlite3 def convert(value): if value.startswith('~'): return value.strip('~') if not value: value = '0' return float(value) conn=sqlite3.connect('food.db') curs=conn.cursor() curs.execute(''' CREATE TABLE food ( id TEXT PRIMARY, desc TEXT, water FLOAT, kcal FLOAT, protein FLOAT, fat FLOAT, ash FLOAT, carbs FLOAT, fiber FLOAT, sugar FLOAT ) ''') query='INSERT INTO food VALUE (?,?,?,?,?,?,?,?,?,?)' for line in open(r'C:\Users\wgh\Downloads\ABBREV.txt'): fields = line.split('^') vals=[convert(f) for f in fields[:field_count]] curs.execute(query,vals) conn.commit() conn.close() ``` 报错内容如下: Traceback (most recent call last): File "E:/python/Lib/site-packages/importdata.py", line 26, in <module> ''') sqlite3.OperationalError: near ",": syntax error

学Python后到底能干什么?网友:我太难了

感觉全世界营销文都在推Python,但是找不到工作的话,又有哪个机构会站出来给我推荐工作? 笔者冷静分析多方数据,想跟大家说:关于超越老牌霸主Java,过去几年间Python一直都被寄予厚望。但是事实是虽然上升趋势,但是国内环境下,一时间是无法马上就超越Java的,也可以换句话说:超越Java只是时间问题罢。 太嚣张了会Python的人!找工作拿高薪这么简单? https://edu....

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

为什么程序猿都不愿意去外包?

分享外包的组织架构,盈利模式,亲身经历,以及根据一些外包朋友的反馈,写了这篇文章 ,希望对正在找工作的老铁有所帮助

Java校招入职华为,半年后我跑路了

何来 我,一个双非本科弟弟,有幸在 19 届的秋招中得到前东家华为(以下简称 hw)的赏识,当时秋招签订就业协议,说是入了某 java bg,之后一系列组织架构调整原因等等让人无法理解的神操作,最终毕业前夕,被通知调往其他 bg 做嵌入式开发(纯 C 语言)。 由于已至于校招末尾,之前拿到的其他 offer 又无法再收回,一时感到无力回天,只得默默接受。 毕业后,直接入职开始了嵌入式苦旅,由于从未...

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

@程序员:GitHub这个项目快薅羊毛

今天下午在朋友圈看到很多人都在发github的羊毛,一时没明白是怎么回事。 后来上百度搜索了一下,原来真有这回事,毕竟资源主义的羊毛不少啊,1000刀刷爆了朋友圈!不知道你们的朋友圈有没有看到类似的消息。 这到底是啥情况? 微软开发者平台GitHub 的一个区块链项目 Handshake ,搞了一个招募新会员的活动,面向GitHub 上前 25万名开发者派送 4,246.99 HNS币,大约价...

用python打开电脑摄像头,并把图像传回qq邮箱【Pyinstaller打包】

前言: 如何悄悄的打开朋友的摄像头,看看她最近过的怎么样,嘿嘿!这次让我带你们来实现这个功能。 注: 这个程序仅限在朋友之间开玩笑,别去搞什么违法的事情哦。 代码 发送邮件 使用python内置的email模块即可完成。导入相应的代码封装为一个send函数,顺便导入需要导入的包 注: 下面的代码有三处要修改的地方,两处写的qq邮箱地址,还有一处写的qq邮箱授权码,不知道qq邮箱授权码的可以去百度一...

做了5年运维,靠着这份监控知识体系,我从3K变成了40K

从来没讲过运维,因为我觉得运维这种东西不需要太多的知识面,然后我一个做了运维朋友告诉我大错特错,他就是从3K的运维一步步到40K的,甚至笑着说:我现在感觉自己什么都能做。 既然讲,就讲最重要的吧。 监控是整个运维乃至整个产品生命周期中最重要的一环,事前及时预警发现故障,事后提供详实的数据用于追查定位问题。目前业界有很多不错的开源产品可供选择。选择一款开源的监控系统,是一个省时省力、效率最高的方...

C++(继承):19---虚基类与虚继承(virtual)

一、菱形继承 在介绍虚继承之前介绍一下菱形继承 概念:A作为基类,B和C都继承与A。最后一个类D又继承于B和C,这样形式的继承称为菱形继承 菱形继承的缺点: 数据冗余:在D中会保存两份A的内容 访问不明确(二义性):因为D不知道是以B为中介去访问A还是以C为中介去访问A,因此在访问某些成员的时候会发生二义性 缺点的解决: 数据冗余:通过下面“虚继承”技术来解决(见下) 访问...

再不跳槽,应届毕业生拿的都比我多了!

跳槽几乎是每个人职业生涯的一部分,很多HR说“三年两跳”已经是一个跳槽频繁与否的阈值了,可为什么市面上有很多程序员不到一年就跳槽呢?他们不担心影响履历吗? PayScale之前发布的**《员工最短任期公司排行榜》中,两家码农大厂Amazon和Google**,以1年和1.1年的员工任期中位数分列第二、第四名。 PayScale:员工最短任期公司排行榜 意外的是,任期中位数极小的这两家公司,薪资...

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

华为初面+综合面试(Java技术面)附上面试题

华为面试整体流程大致分为笔试,性格测试,面试,综合面试,回学校等结果。笔试来说,华为的难度较中等,选择题难度和网易腾讯差不多。最后的代码题,相比下来就简单很多,一共3道题目,前2题很容易就AC,题目已经记不太清楚,不过难度确实不大。最后一题最后提交的代码过了75%的样例,一直没有发现剩下的25%可能存在什么坑。 笔试部分太久远,我就不怎么回忆了。直接将面试。 面试 如果说腾讯的面试是挥金如土...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

win10暴力查看wifi密码

刚才邻居打了个电话说:喂小灰,你家wifi的密码是多少,我怎么连不上了。 我。。。 我也忘了哎,就找到了一个好办法,分享给大家: 第一种情况:已经连接上的wifi,怎么知道密码? 打开:控制面板\网络和 Internet\网络连接 然后右击wifi连接的无线网卡,选择状态 然后像下图一样: 第二种情况:前提是我不知道啊,但是我以前知道密码。 此时可以利用dos命令了 1、利用netsh wlan...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

女朋友过生日,我花了20分钟给她写了一个代理服务器

女朋友说:“看你最近挺辛苦的,我送你一个礼物吧。你看看想要什么,我来准备。” 我想了半天,从书到鞋子到电子产品最后到生活用品,感觉自己什么都不缺,然后和她说:“你省省钱吧,我什么都不需要。” 她坚持要送:“不行,你一定要说一个礼物,我想送你东西了。” 于是,我认真了起来,拿起手机,上淘宝逛了几分钟,但还是没能想出来缺点什么,最后实在没办法了:“这样吧,如果你实在想送东西,那你就写一个代理服务器吧”...

记一次腾讯面试,我挂在了最熟悉不过的队列上……

腾讯后台面试,面试官问:如何自己实现队列?

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

程序员写出这样的代码,能不挨骂吗?

当你换槽填坑时,面对一个新的环境。能够快速熟练,上手实现业务需求是关键。但是,哪些因素会影响你快速上手呢?是原有代码写的不够好?还是注释写的不够好?昨夜...

带了6个月的徒弟当了面试官,而身为高级工程师的我天天修Bug......

即将毕业的应届毕业生一枚,现在只拿到了两家offer,但最近听到一些消息,其中一个offer,我这个组据说客户很少,很有可能整组被裁掉。 想问大家: 如果我刚入职这个组就被裁了怎么办呢? 大家都是什么时候知道自己要被裁了的? 面试软技能指导: BQ/Project/Resume 试听内容: 除了刷题,还有哪些技能是拿到offer不可或缺的要素 如何提升面试软实力:简历, 行为面试,沟通能...

!大部分程序员只会写3年代码

如果世界上都是这种不思进取的软件公司,那别说大部分程序员只会写 3 年代码,恐怕就没有程序员这种职业。

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

立即提问
相关内容推荐