首页 \ 问答 \ Python:列表操作(Python: List operations)

Python:列表操作(Python: List operations)

我是100%新的python,我知道我需要阅读更多,但我需要现在就做这个任务,这就是为什么我使用python。 这是我的代码:

outputList = []

for line in open('cron.log', 'r'):
   m = line[45:47]
   outputList.append(m)

所以我打开文件,通过行读取,并追加我需要的2个字符到列表中。 现在我想从end (或列表的beginningbeginning ,将该位置的elementelement before (或behind )的element进行比较。 我怎样才能做到这一点? 在C ++中,我会做iterrator ,使用front()pop_front()等,但我对python :(


I am 100% new to python, I know I need to read more but I need to do this task right now that's why I am using python for it. Here is my code:

outputList = []

for line in open('cron.log', 'r'):
   m = line[45:47]
   outputList.append(m)

So I opened the file, read through lines, and append the 2 chars I need into a list. Now I want to go from the end (or beginning of the list), comparing the element at that position with the element right before (or behind) it. How can I do that? In C++ I would be doing iterrator, using front(), pop_front() or such but I am clueless about python :(


原文:https://stackoverflow.com/questions/6456716
更新时间:2022-02-16 09:02

最满意答案

你可能只想设置publicPath: '/'

publicPath视为您的资产相对于面向公众的域的根目录。 如果您的服务器向example.com提供/dist文件,这意味着/dist/images example.com/images /dist/images中的资源可以在example.com/images公开访问( file-loader已经添加了您目击的/images位)。


You probably just want to set publicPath: '/'.

Think of publicPath as the directory of your assets relative to the root of the public facing domain. If your server is serving files from /dist to example.com, that would mean that assets in /dist/images are publicly accessible at example.com/images (file-loader already adds the /images bit as you've witnessed).

相关问答

更多
  • 关于问题#1 一旦在webpack.config中配置了文件加载器,每当使用import / require时,都会针对所有加载器测试路径,如果有匹配,则会通过该加载器传递内容。 在你的情况下,它匹配 {test: /\.(jpe?g|png|gif|svg)$/i, loader: "file-loader?name=/public/icons/[name].[ext]"} 因此您会看到发出的图像 dist/public/icons/imageview_item_normal.png 这是想要的行为。 ...
  • 你可能只想设置publicPath: '/' 。 将publicPath视为您的资产相对于面向公众的域的根目录。 如果您的服务器向example.com提供/dist文件,这意味着/dist/images example.com/images /dist/images中的资源可以在example.com/images公开访问( file-loader已经添加了您目击的/images位)。 You probably just want to set publicPath: '/'. Think of publ ...
  • url-loader会将文件编码为base64,并将它们内联,而不是将它们作为单独的文件加载到另一个请求中。 一个base64编码的文件可能看起来像这样: data:;base64,aW1wb3J0IFJlYWN0IGZ... 这将被添加到你的包中。 url-loader will encode files to base64 and include them inline rather than having them loaded as separate files with another requ ...
  • 似乎有2个ExtractTextPlugins(用于css和less测试导致问题),因为我没有任何css文件,我删除了第一个,它现在按预期工作。 It seems that having the 2 ExtractTextPlugins (for the css & less tests were causing the problems) as I don't have any css files I removed the first and it's now working as expected.
  • 发现错误:变量$ {event.image}通过JSON加载。 在少数情况下,它有一个字符串,在其他情况下是空的。 空着的人正在抛出一个错误。 Found the error: the variable ${event.image} was loaded via JSON. in a few cases, it has a string, in other it was empty. the empty ones are throwing an error.
  • 我找不到任何方式或插件来完成这项工作,所以我创建了一个自定义的webpack插件,它在我的情况下完美工作。 如果有人遇到类似的情况,你可能也想使用这个插件webpack-file-preprocessor-plugin 这是一个非常轻量级的webpack插件,它允许您在文件或资产最终发布之前预先处理使用file-loader加载的文件或资产。 由于这是一个非常通用的插件,您可以使用它在webpack最终发布之前对资产进行任何类型的自定义预处理。 本示例演示如何使用此插件来缩小使用file-loader加载的 ...
  • 我发现了一个修复,在ExtractPlugin中覆盖了publicPath就是这样做的: ExtractPlugin.extract('style', 'css!sass', { publicPath: './' }) I found a fix, overriding publicPath in the ExtractPlugin was what did it: ExtractPlugin.extract('style', 'css!sass', { publicPath: './' })
  • file-loader尊重output.publicPath ,但由于您没有设置它,因此生成的路径将是相对路径。 您可以将公共路径设置为/ 。 output: { path: path.resolve(__dirname, 'dist'), filename: 'js/app.js', publicPath: '/' }, 这将影响处理任何资产的其他加载器和插件。 这通常是您想要的,因此建议使用,但如果您只想为特定文件更改它, publicPath可以在file-loader上使用 ...
  • 在解决问题的同时让事情变得简单明了 确保webpack config的output.path指向目标文件夹。 我相信它的app文件夹在你的情况。 请注意output.path采用绝对路径,即使用path模块。 在file-loader取出publicPath直到我们解决问题。 使用file-loader的outputPath相对路径,即assets/img 一旦你做了这些改变,事情应该按预期工作。 然后,您可以尝试根据您的需要publicPath用于file-loader publicPath 。 一般来说 ...
  • 为了解释elmeister的评论, images/logo-icon.png是一个相对路径,它依赖于当前路径。 因此,来自url http://localhost:8080/chef/对images/logo-icon.png的请求会导致请求http://localhost:8080/chef/images/logo-icon.png 。 /images/logo-icon.png是一个绝对路径,确保路径始终基于站点的根,无论当前路径是什么。 因此,从url http://localhost:8080/ch ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。