会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 133542个问题

老师,我这个字符串类型能打印出来,但是内容就是打印不出来,老是有什么错误,帮我看一下

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>跨域传输name</title>
	</head>
	<body>
		<button>跨域传输</button>
		<script>
		/* 
		 window.name
		 描述:是页面在切换之后,甚至域名更改之后仍然会存储信息的容器
		 说明:借助window.name可以实现页面之间的数据传递,陈伟跨域传输
		
		 如果想要获取一个页面内的信息,就必须先加载这个页面
		
		 */
		var name = 123;
		console.log(name);
		console.log(typeof(name));  
		var age = 123;
		console.log(typeof(age));
		
		var btn = document.querySelector('button');
		btn.onclick = function(){
			var iframe = document.createElement('iframe');
			// 加载保存信息页面
			iframe.src = '01window对象.html';
			iframe.style.display = 'none';
			document.body.appendChild(iframe);
			//当iframe加载完毕,意味着window.name的内容已经被赋予完毕
			iframe.onload = function(e){
				//contentWindow 返回指定的iframe的窗口对象。
				var iframeWName=e.target.contentWindow.name;
				eval(iframeWName);
				console.log(typeof(iframeWName));
				console.log(iframeWName);
			}
			
			
		}
		
		
		</script>
	</body>
</html>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>window顶级对象</title>
	</head>
	<body>
		<div>O(∩_∩)O</div>
		<script>
		/* 
			概念:window对象是BOM的具象化表现形式。
			ps:因为window对象是js中的顶级对象,因此所有定义在全局作用域中的
				变量、函数都会变成window对象的属性和方法
				window包含document
		 
		 */
		//重新打开一个窗口
		//window.open('http://www.baidu.com');
		//关闭当前窗口
		//window.close(); 
		var div = window.document.querySelector('div');
		div.onclick = function(e){
			div.style.color = 'gold';
			
		}
		
		
		var page = '跨域传输';
		window.name = 'var page = 跨域传输';
		
		</script>
	</body>
</html>


WEB前端全系列/第二阶段:JavaScript编程模块/面向对象编程 37067楼

package com.yz;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;

/**
 * 定义文件拷贝工具类
 */
public class FileCopyTools {
    public static void main(String[] args) {
        //拷贝图片
        FileCopyTools.copyFile("D:/a.jpg","D:/c.jpg");
    }
    public static void copyFile(String src,String des){
        //声明缓冲流
        BufferedInputStream bis = null;
        BufferedOutputStream bos = null;
        //surround  by try catch
        try{
            //实例化缓冲流
            bis = new BufferedInputStream(new FileInputStream(src));
            bos = new BufferedOutputStream(new FileOutputStream(des));
            //读取文件
            int temp ;
            while ((temp=bis.read())!=-1){
                bos.write(temp);
            }
            //清空缓存区,写入到目的文件
            bos.flush();
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            try{
                if (bis!=null){
                    bis.close();
                }
                if (bos!=null){
                    bos.close();
                }
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
}

问题:老师帮忙看下这个代码有错误或者有什么要改进的地方吗?拷贝图片功能可以实现。

JAVA 全系列/第二阶段:JAVA 基础深化和提高/IO 流技术(旧) 37069楼
Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 37073楼
JAVA 全系列/第六阶段:JavaWeb开发/JSP技术详解(旧) 37074楼
Python 全系列/第十六阶段:Python 爬虫开发/scrapy框架使用 37075楼
JAVA 全系列/第四阶段:数据库与AI协同技术实战/Oracle 数据库的使用 37076楼

HTTP Status 500 - {msg=SolrCore 'collection1' is not available due to init failure: Could not load conf for core collection1: Schema Parsing Failed: Invalid byte 3 of 3-byte UTF-8 sequence.. Schema file is /usr/local/solrhome/solr/collection1/conf/schema.xml,trace=org.apache.solr.common.SolrException: SolrCore 'collection1' is not available due to init failure: Could not load conf for core collection1: Schema Parsing Failed: Invalid byte 3 of 3-byte UTF-8 sequence.. Schema file is /usr/local/solrhome/solr/collection1/conf/schema.xml at org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:745) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:307) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:207) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: org.apache.solr.common.SolrException: Could not load conf for core collection1: Schema Parsing Failed: Invalid byte 3 of 3-byte UTF-8 sequence.. Schema file is /usr/local/solrhome/solr/collection1/conf/schema.xml at org.apache.solr.core.ConfigSetService.getConfig(ConfigSetService.java:66) at org.apache.solr.core.CoreContainer.create(CoreContainer.java:489) at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:255) at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:249) at java.util.concurrent.FutureTask.run(FutureTask.java:266) ... 3 more Caused by: org.apache.solr.common.SolrException: Schema Parsing Failed: Invalid byte 3 of 3-byte UTF-8 sequence.. Schema file is /usr/local/solrhome/solr/collection1/conf/schema.xml at org.apache.solr.schema.IndexSchema.readSchema(IndexSchema.java:599) at org.apache.solr.schema.IndexSchema.<init>(IndexSchema.java:166) at org.apache.solr.schema.IndexSchemaFactory.create(IndexSchemaFactory.java:55) at org.apache.solr.schema.IndexSchemaFactory.buildIndexSchema(IndexSchemaFactory.java:69) at org.apache.solr.core.ConfigSetService.createIndexSchema(ConfigSetService.java:90) at org.apache.solr.core.ConfigSetService.getConfig(ConfigSetService.java:62) ... 7 more Caused by: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 3 of 3-byte UTF-8 sequence. at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:691) at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:435) at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1762) at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.scanData(XMLEntityScanner.java:1261) at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanComment(XMLScanner.java:778) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanComment(XMLDocumentFragmentScannerImpl.java:1038) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2988) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:348) at org.apache.solr.core.Config.<init>(Config.java:135) at org.apache.solr.core.Config.<init>(Config.java:87) at org.apache.solr.schema.IndexSchema.readSchema(IndexSchema.java:445) ... 12 more ,code=500}

不知道问题出在哪,好像报什么utf-8三字节错误,是什么原因

JAVA 全系列/(旧的隐藏)第七阶段:JAVA 高级技术/Solr 37078楼

"""画图本的基本编程"""

from tkinter.filedialog import *
from tkinter.colorchooser import *

"""窗口的宽度和高度"""
win_width = 900
win_height = 450

class Application(Frame):

    def __init__(self,master=None,bgcolor="#000000"):
        super().__init__(master)
        self.master=master
        self.bgcolor = bgcolor
        self.x = 0
        self.y = 0
        self.fgcolor = "#ff0000"
        self.lastDraw = 0
        self.startDrawFlag = False
        self.pack()
        self.creakWidget()


    def creakWidget(self):

        """创建绘图区域"""
        self.drawpad = Canvas(root, width=win_width, height=win_height*0.9, bg=self.bgcolor)
        self.drawpad.pack()

        """创建按钮"""
        btn_start = Button(root, text="开始",  name="start")
        btn_start.pack(side="left", padx=10)
        btn_pen = Button(root, text="画笔", name="pen")
        btn_pen.pack(side="left", padx=10)
        btn_rect = Button(root, text="矩形", name="rect")
        btn_rect.pack(side="left", padx=10)
        btn_clear = Button(root, text="清屏", name="clear")
        btn_clear.pack(side="left", padx=10)
        btn_erasor = Button(root, text="橡皮擦", name="erasor")
        btn_erasor.pack(side="left", padx=10)
        btn_line = Button(root, text="直线", name="line")
        btn_line.pack(side="left", padx=10)
        btn_lineArrow = Button(root, text="箭头直线", name="lineArrow")
        btn_lineArrow.pack(side="left", padx=10)
        btn_color = Button(root, text="颜色", name="color")
        btn_color.pack(side="left", padx=10)

        """事件的处理"""
        btn_pen.bind_class("Button", "<1>", self.eventManager)
        self.drawpad.bind("<ButtonRelease-1>", self.stopDraw)

        """增添颜色快捷键处理"""
        root.bind("<KeyPress-r>", self.kuaijiejian)
        root.bind("<KeyPress-g>", self.kuaijiejian)
        root.bind("<KeyPress-y>", self.kuaijiejian)

    def eventManager(self,event):
        name = event.widget.winfo_name()
        print(name)

        if name == "line":
            self.drawpad.bind("<B1-Motion>", self.myLine)
        elif name == "lineArrow":
            self.drawpad.bind("<B1-Motion>", self.mylineArrow)
        elif name == "rect":
            self.drawpad.bind("<B1-Motion>", self.myRect)
        elif name == "pen":
            self.drawpad.bind("<B1-Motion>", self.myPen)
        elif name == "erasor":
            self.drawpad.bind("<B1-Motion>", self.myErasor)
        elif name == "clear":
            self.drawpad.delete("all")
        elif name == "color":
            c = askcolor(color=self.fgcolor, title="选择画笔颜色")
            self.fgcolor = c[1]

    def startDraw(self,event):
        self.drawpad.delete(self.lastDraw)

        if not self.startDrawFlag:
            self.startDrawFlag = True
            self.x = event.x
            self.y = event.y

    def stopDraw(self,event):
        self.startDrawFlag = False
        self.lastDraw = 0


    def myLine(self,event):
        self.startDraw(event)
        self.lastDraw = self.drawpad.create_line(self.x, self.y, event.x, event.y, fill=self.fgcolor)

    def mylineArrow(self,event):
        self.startDraw(event)
        self.lastDraw = self.drawpad.create_line(self.x, self.y, event.x, event.y, arrow=LAST, fill=self.fgcolor)

    def myRect(self,event):
        self.startDraw(event)
        self.lastDraw = self.drawpad.create_rectangle(self.x, self.y, event.x, event.y, outline=self.fgcolor)

    def myPen(self,event):
        self.startDraw(event)
        self.drawpad.create_line(self.x, self.y, event.x, event.y, fill=self.fgcolor)
        self.x = event.x
        self.y = event.y

    def myErasor(self,event):
        self.startDraw(event)
        self.drawpad.create_rectangle(event.x-5, event.y-5, event.x, event.y, fill=self.bgcolor)
        self.x = event.x
        self.y = event.y

    def kuaijiejian(self,event):
        if event.char == "r":
            self.fgcolor = "#ff0000"
        if event.char == "g":
            self.fgcolor = "#00ff00"
        if event.char == "y":
            self.fgcolor = "#ffff00"




if __name__ == "__main__":
    root = Tk()
    root.geometry(str(win_width)+"x"+str(win_height)+"+200+300")
    root.title("画图简易本")
    app = Application(master=root)
    root.mainloop()

老师我想问一下,怎么修改代码才能让画出的直线的颜色不停的变化,我想用for循环来实现,但是不知道怎么写。

Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 37079楼
Python 全系列/第六阶段:数据库与AI协同技术实战/MySQL数据库的使用 37080楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637