我无法为这段代码创建文档,我想我的javadoc的coomad是不对的,我读到它但不明白,任何人都可以通过javadoc cammand纠正
class abc
{/** documentaion line 1
*
* */
public static void main(String a[])
{/** documentaion line 2
*
* */
System.out.println("documentation");
}
}
Run Code Online (Sandbox Code Playgroud)
Error: C:\Program Files\Java\jdk1.6.0\bin>javac abc.java C:\Program Files\Java\jdk1.6.0\bin>java abc documentation C:\Program Files\Java\jdk1.6.0\bin>javadoc abc Loading source files for package abc... javadoc: warning - No source files for package abc Constructing Javadoc information... javadoc: warning - No source files for package abc javadoc: error - No public or protected classes found to document. 1 error …
作为创建VBA脚本以将当前选定图像的大小调整为100%x 100%的第一步,我试图在http://msdn.microsoft.com/en-us/library/ee814736(v)中重现该示例= office.14).aspx.宏非常简单:
Sub Test()
MsgBox ("Hello world")
End Sub
Run Code Online (Sandbox Code Playgroud)
VBA脚本只是在"Project1"中创建,默认情况下会在按下Alt + F11时打开.但是,在尝试运行VBA脚本时,我不断收到错误"Sub或Function not defined"(图1和图2).
如何使VBA脚本"可访问"Outlook?
图1在Microsoft Outlook中运行"测试"宏
图2"Sub或Function not defined"错误,后台有模块树
Dateutil的timedelta对象似乎有一个自定义__str__方法:
In [1]: from datetime import timedelta
In [2]: td = timedelta(hours=2)
In [3]: str(td)
Out[3]: '2:00:00'
Run Code Online (Sandbox Code Playgroud)
我想做的是timedelta从字符串表示中重新创建一个对象.然而,据我所知,该datetime.parser.parse方法将始终返回一个datetime.datetime对象(参见https://dateutil.readthedocs.io/en/stable/parser.html):
In [4]: import dateutil.parser
In [5]: dateutil.parser.parse(str(td))
Out[5]: datetime.datetime(2016, 11, 25, 2, 0)
Run Code Online (Sandbox Code Playgroud)
我现在看到的唯一方法就是将转换时间值转换为天,小时和分钟,"破坏一些令人作呕的简单(但冗长)数学"以获得秒,分,小时等,并将这些传递__init__给新的timedelta.或者是否有更简单的方法?
我试图理解Python 模块中的类装置unittest。为了加快测试速度,我想在每个类中创建一个“昂贵”的连接对象一次。乍一看,我想到这样做:
import unittest
import rethinkdb as r
class TestRethink(unittest.TestCase):
conn = r.connect('localhost', 28016)
def test_table_list(self):
r.table_list().run(self.conn)
if __name__ == "__main__":
unittest.main()
Run Code Online (Sandbox Code Playgroud)
然而,从文档看来,应该这样做:
import unittest
import rethinkdb as r
class TestRethink(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.conn = r.connect('localhost', 28016)
def test_table_list(self):
r.table_list().run(self.conn)
if __name__ == "__main__":
unittest.main()
Run Code Online (Sandbox Code Playgroud)
这两种方法有什么区别?在这两种情况下,RethinkDB 连接对象都是类变量,不是吗?
我目前正在使用以下命令行参数的Scrapy:
scrapy crawl my_spider -o data.json
Run Code Online (Sandbox Code Playgroud)
但是,我更喜欢在Python脚本中"保存"此命令.在https://doc.scrapy.org/en/latest/topics/practices.html之后,我有以下脚本:
import scrapy
from scrapy.crawler import CrawlerProcess
from apkmirror_scraper.spiders.sitemap_spider import ApkmirrorSitemapSpider
process = CrawlerProcess({
'USER_AGENT': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)'
})
process.crawl(ApkmirrorSitemapSpider)
process.start() # the script will block here until the crawling is finished
Run Code Online (Sandbox Code Playgroud)
但是,从文档中我不清楚-o data.json命令行参数的等效内容应该在脚本中.如何让脚本生成JSON文件?
我有一个 Django 模型SessionType,其定义类似于以下内容:
from django import models
class SessionType(models.Model):
class Meta:
ordering = ['title']
title = models.CharField(max_length=255, unique=True)
Run Code Online (Sandbox Code Playgroud)
起初,unique=True约束并不存在;我刚刚添加了它,然后运行python manage.py makemigrations. 这导致了以下迁移 ( 0163_auto_20180627_1309.py):
# -*- coding: utf-8 -*-
# Generated by Django 1.11.9 on 2018-06-27 20:09
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('lucy_web', '0162_merge_20180531_0009'),
]
operations = [
migrations.AlterField(
model_name='sessiontype',
name='title',
field=models.CharField(max_length=255, unique=True),
),
]
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试时python manage.py migrate,出现以下错误:
django.db.utils.IntegrityError:重复键值违反唯一约束“django_migrations_pkey”详细信息:键(id)=(326)已经存在。
以下是命令和完整的回溯:
(venv) Kurts-MacBook-Pro-2:lucy-web …Run Code Online (Sandbox Code Playgroud) 这个问题与Serverless offline not getting route几乎相同,但由于没有回答这个问题,我再次问。我正在尝试关注这篇文章https://medium.com/@awesome1888/how-to-use-serverless-locally-with-webpack-and-docker-5e268f71715,了解如何使用无服务器部署 Lambda 函数。
我有一个具有以下结构的目录:
> tree -I node_modules
.
??? package-lock.json
??? package.json
??? serverless.yml
??? src
? ??? handler.js
? ??? index.js
??? webpack.config.js
Run Code Online (Sandbox Code Playgroud)
哪里serverless.yml读
service: my-first-lambda
plugins:
- serverless-webpack
- serverless-offline
provider:
name: aws
runtime: nodejs10.x
region: us-east-1
stage: dev
functions:
hello:
handler: src/handler.main
events:
- http:
path: /hello
method: any
custom:
webpack:
includeModules: true
Run Code Online (Sandbox Code Playgroud)
src/index.js 阅读
import moment from 'moment';
const handler = async (event, context) => …Run Code Online (Sandbox Code Playgroud) 我正在尝试理解一个包含.h文件的C程序
#define random ((float) rand() / (float)((1 << 31) - 1))
Run Code Online (Sandbox Code Playgroud)
C程序还包括<math.h>.
我的猜测是,这只是在区间[0,1]上从均匀分布产生一个随机数; 它是否正确?
我正在尝试运行一个刮刀,其输出日志结束如下:
2017-04-25 20:22:22 [scrapy.spidermiddlewares.httperror] INFO: Ignoring response <429 http://www.apkmirror.com/apk/instagram/instagram-instagram/instagram-instagram-9-0-0-34920-release/instagram-9-0-0-4-android-apk-download/>: HTTP status code is not handled or not allowed
2017-04-25 20:22:22 [scrapy.core.engine] INFO: Closing spider (finished)
2017-04-25 20:22:22 [scrapy.statscollectors] INFO: Dumping Scrapy stats:
{'downloader/request_bytes': 16048410,
'downloader/request_count': 32902,
'downloader/request_method_count/GET': 32902,
'downloader/response_bytes': 117633316,
'downloader/response_count': 32902,
'downloader/response_status_count/200': 121,
'downloader/response_status_count/429': 32781,
'finish_reason': 'finished',
'finish_time': datetime.datetime(2017, 4, 25, 18, 22, 22, 710446),
'log_count/DEBUG': 32903,
'log_count/INFO': 32815,
'request_depth_max': 2,
'response_received_count': 32902,
'scheduler/dequeued': 32902,
'scheduler/dequeued/memory': 32902,
'scheduler/enqueued': 32902,
'scheduler/enqueued/memory': 32902,
'start_time': datetime.datetime(2017, 4, 25, 17, 54, 36, 621481)} …Run Code Online (Sandbox Code Playgroud) 我正在尝试运行带有两个“扩展”的 Scrapy 蜘蛛:
举个例子,我用的刮刀quotes.toscrape.com在https://github.com/scrapy-plugins/scrapy-splash/tree/master/example。这是我的目录结构:
.
??? docker-compose.yml
??? example
??? Dockerfile
??? scrapy.cfg
??? scrashtest
??? __init__.py
??? settings.py
??? spiders
??? __init__.py
??? quotes.py
Run Code Online (Sandbox Code Playgroud)
其中example目录是从克隆scrapy-splash库。我添加了以下docker-compose.yml文件:
version: '3'
services:
scraper:
build: ./example
environment:
- http_proxy=http://tor-privoxy:8118
links:
- tor-privoxy
- splash
tor-privoxy:
image: rdsubhas/tor-privoxy-alpine
splash:
image: scrapinghub/splash
Run Code Online (Sandbox Code Playgroud)
settings.py我在文件中更改了以下内容SPLASH_URL:
# SPLASH_URL = 'http://127.0.0.1:8050/'
SPLASH_URL = 'http://splash:8050'
Run Code Online (Sandbox Code Playgroud)
因为 Splash 不是在本地主机上运行,而是在一个名为splash. 在 …
python ×5
scrapy ×3
c ×1
datetime ×1
django ×1
docker ×1
java ×1
javadoc ×1
javascript ×1
outlook ×1
outlook-vba ×1
random ×1
routes ×1
serverless ×1
vba ×1
web-scraping ×1